#ifndef KEYBOARD_H
#define KEYBOARD_H

#include <QDialog>
#include <QLayout>
#include <QMessageBox>
#include "keyboardkey.h"

namespace Ui {
    class Keyboard;
}

enum type_keyboard
{
    AZERTY, QWERTY, DIGIT
};

class Keyboard : public QDialog
{
    Q_OBJECT
protected:
    virtual void showEvent ( QShowEvent * event );

signals:
    void putText(QString);
    void Backspace();

public:
    explicit Keyboard(type_keyboard type = AZERTY, QWidget *parent = 0);
    ~Keyboard();
    void setFonction_Edit(void (*p)(const QString &));
    static type_keyboard str2layout(QString str);

private:
    Ui::Keyboard *ui;
    type_keyboard type;
    bool shift;
    bool special;
    void clearLayout(QLayout *l);
    void Init_Top();
    void Init_Bottom();
    void Init_Digit();
    void Init_Azerty();
    void Init_Qwerty();
    void Init_Special();
    void To_Azerty();
    void To_Qwerty();
    void To_Special_Characters();
    void To_Digit();
    void Maximize_Caracters();
    void Minimize_Caracters();
    void Resize_Keyboard();
    QList <KeyboardKey *> * List_Button;

    KeyboardKey * pushButton_Maj;
    KeyboardKey * pushButton_Space;
    KeyboardKey * pushButton_Back;
    KeyboardKey * pushButton_Special;
    KeyboardKey * pushButton_Return;

    KeyboardKey * pushButton_A;
    KeyboardKey * pushButton_B;
    KeyboardKey * pushButton_C;
    KeyboardKey * pushButton_D;
    KeyboardKey * pushButton_E;
    KeyboardKey * pushButton_F;
    KeyboardKey * pushButton_G;
    KeyboardKey * pushButton_H;
    KeyboardKey * pushButton_I;
    KeyboardKey * pushButton_J;
    KeyboardKey * pushButton_K;
    KeyboardKey * pushButton_L;
    KeyboardKey * pushButton_M;
    KeyboardKey * pushButton_N;
    KeyboardKey * pushButton_O;
    KeyboardKey * pushButton_P;
    KeyboardKey * pushButton_Q;
    KeyboardKey * pushButton_R;
    KeyboardKey * pushButton_S;
    KeyboardKey * pushButton_T;
    KeyboardKey * pushButton_U;
    KeyboardKey * pushButton_V;
    KeyboardKey * pushButton_W;
    KeyboardKey * pushButton_X;
    KeyboardKey * pushButton_Y;
    KeyboardKey * pushButton_Z;

    KeyboardKey * pushButton_1;
    KeyboardKey * pushButton_2;
    KeyboardKey * pushButton_3;
    KeyboardKey * pushButton_4;
    KeyboardKey * pushButton_5;
    KeyboardKey * pushButton_6;
    KeyboardKey * pushButton_7;
    KeyboardKey * pushButton_8;
    KeyboardKey * pushButton_9;
    KeyboardKey * pushButton_0;

    KeyboardKey * pushButton_digit_1;
    KeyboardKey * pushButton_digit_2;
    KeyboardKey * pushButton_digit_3;
    KeyboardKey * pushButton_digit_4;
    KeyboardKey * pushButton_digit_5;
    KeyboardKey * pushButton_digit_6;
    KeyboardKey * pushButton_digit_7;
    KeyboardKey * pushButton_digit_8;
    KeyboardKey * pushButton_digit_9;
    KeyboardKey * pushButton_digit_0;
    KeyboardKey * pushButton_digit_point;

    KeyboardKey * pushButton_virg;
    KeyboardKey * pushButton_point;

    KeyboardKey * pushButton_circ;
    KeyboardKey * pushButton_ugrav;
    KeyboardKey * pushButton_interog;
    KeyboardKey * pushButton_ptvirg;
    KeyboardKey * pushButton_2pt;
    KeyboardKey * pushButton_exclam;
    KeyboardKey * pushButton_equal;
    KeyboardKey * pushButton_slash;
    KeyboardKey * pushButton_pourc;
    KeyboardKey * pushButton_dollar;
    KeyboardKey * pushButton_tremat;
    KeyboardKey * pushButton_plus;
    KeyboardKey * pushButton_antislash;
    KeyboardKey * pushButton_at;
    KeyboardKey * pushButton_tiret;
    KeyboardKey * pushButton_underscore;
    KeyboardKey * pushButton_cote;
    KeyboardKey * pushButton_dbl_cote;
    KeyboardKey * pushButton_tild;
    KeyboardKey * pushButton_diese;
    KeyboardKey * pushButton_amp;
    KeyboardKey * pushButton_parenthese_left;
    KeyboardKey * pushButton_parenthese_right;
    KeyboardKey * pushButton_crochet_left;
    KeyboardKey * pushButton_crochet_right;
    KeyboardKey * pushButton_accolade_left;
    KeyboardKey * pushButton_accolade_right;
    KeyboardKey * pushButton_star;
    KeyboardKey * pushButton_pipe;
    KeyboardKey * pushButton_c_cedille;
    KeyboardKey * pushButton_a_grave;
    KeyboardKey * pushButton_euro;
    KeyboardKey * pushButton_micro;
    KeyboardKey * pushButton_degres;
    KeyboardKey * pushButton_copyright;
    KeyboardKey * pushButton_inferior;
    KeyboardKey * pushButton_superior;
    KeyboardKey * pushButton_carre;

    void (*edit_widget)(const QString &);
    void hide_all();

public slots:
    void Put(QString text);
    void Shift();
    void Special();
    void Back();
    void Change_Layout(type_keyboard layout);
};

#endif // KEYBOARD_H
